package book.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 分页bean
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageBean<T> implements Serializable {
    private int pageNo      = 1;     //当前页
    private int pageSize    = 5;   //每页大小
    private int totalCount;         //总记录数
    private int totalPage;          //总页数
    private List<T> list;           //查询结果
    private DynamicParameter parameter;//查询参数
    /**
     * 设计总记录数时，需要计算总页数
     * @param totalCount
     */
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        if(totalCount % pageSize == 0) {
            this.totalPage = totalCount / pageSize;
        }else{
            this.totalPage = totalCount / pageSize + 1;
        }
    }
}
